import request from '@/utils/request'
import { getStoreId } from '@/utils/index';
import querystring from 'querystring'

export function getClients () {
  return request.get('/platform/customer/allCustomer')
}

/**
 * 查询客户详情
 * @param {*} id 
 */
export function getClientById (id) {
  return request.get('/client/detail/' + id)
}
/**
 * 编辑查询详情接口
 * @param {*} id 
 */
export function clientFindById (id) {
  return request.get(`/client/findById/${id}`)
}

export function addClient (param) {
  return request.post('/client/save', param)
}

/**
 * 客户管理删除接口
 * @param {*} id 
 */
export function deleteClient (id) {
  return request.delete('/client/del/' + id)
}

/**
 * 客户管理分页接口
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function clientList (param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/client/page', data)
}

export function updateClient (param) {
  return request.post('/client/editSave', param)
}

export function getClientDict () {
  return request.get('/platform/customer/dict')
}
/**
 * 根据车或客户信息找到客户--暂时用不到
 * @param {*} likeName 
 */
export function findClientAndCar (likeName) {
  return request.get(`/client/findClientAndCar/${likeName}`)
}
/**
 * 根据车或客户信息找到客户-使用中
 */
export function clientSelect (likeName) {

  return request.post(`/client/select`, { param: likeName, storeId: getStoreId() })
}

/**
 * 查询客户会员信息
 * @param {*} id 
 */
export function findMemberById (id) {
  return request.get(`/client/findMemberById/${id}`)
}
/**
 * 发送验证码
 * @param {*} phone 
 */
export function clientSendSmsPhone (phone) {
  return request.get(`/client/sendSmsPhone/${phone}`)
}
/**
 * 验证码是否正确
 * @param {*} phone 
 * @param {*} code 
 */
export function clientCheckSendSmsPhone (phone, code) {
  return request.get(`/client/checkSendSmsPhone/${phone}/${code}`)
}


